<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telephone=no">
    <meta content="yes" name="apple-touch-fullscreen"/>
    <title>扑妞推荐</title>
    <link rel="stylesheet" href="/static/css/base.css?v={$staticVersion}"/>
    <link rel="stylesheet" href="/static/css/equip.css?v={$staticVersion}"/>
    <link rel="stylesheet" href="/static/css/show/dropload.css?v={$staticVersion}"/>
</head>
    
<body>
    <img class="ad-banner" src="/static/images/img/tg.jpg">
    <nav class="sort-nav line-gray">
        <div class="btn-sort">
            <button {if $sort=='1'}class="on"{/if} data-sort=1 onclick="location.href='gearNewsList?sort=1'">时间排序</button>
            <button {if $sort=='2'}class="on"{/if} data-sort=2 onclick="location.href='gearNewsList?sort=2'">热度排序</button>
        </div>
    </nav>
    <dl class="pn-recommend">  
        <div class="content">
            <div class="lists"></div>
        </div>
        <script id="template" type="text/html">
        <% for(var i=0;i<list.length;i++){ %>
        <a href="joggers://news/<%=list[i].news_id%>" onclick="trackevent('homenewsmore',<%=list[i].news_id%>)">
        <dd class="line-gray-bottom p10">
            <h3><%=list[i].title%></h3>
            <div class="img-list">
                <% for(var j=0;j<list[i].thumb_img.length;j++){ %>
                <img src="<%=list[i].thumb_img[j]%>">
                <% } %>
            </div>
        </dd>
        </a>
        <% } %>
        </script> 
    </dl>
    <!-- 扑妞推荐 -->
    <div class="back-top"></div>
<script src="/static/js/show/zepto.min.js?v={$staticVersion}"></script>
<script src="/static/js/show/template-native.js?v={$staticVersion}"></script>
<script src="/static/js/show/dropload.min.js?v={$staticVersion}"></script>
<script src="/static/js/show/zepto.scroll.js?v={$staticVersion}"></script>
<script src="/static/js/show/gear.js?v={$staticVersion}"></script>

<script>
    $(function(){
    // 页数
    var page = 0;
    function getUrlParam(name,defaultValue) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return defaultValue; //返回参数值
        }

     var isload = false;
    // dropload
    $('.content').dropload({
        scrollArea : window,
        domDown : {
            domNoData : function(){
                return page!=1 ? '<div class="dropload-noData">没有更多了</div>':'';
            }
        },
        loadDownFn : function(me){
            if(isload){
                return;
            }
            page++;
            isload=true;
            $.ajax({
                type: 'GET',
                url: '/ajax/gearNewsList?page='+page+'&sort='+getUrlParam('sort',1),
                dataType: 'json',
                success: function(data){
                    var arrLen = data.list.length;
                    if(arrLen > 0){
                        $('.lists').append(template('template',{'list':data.list}));
                    }else{
                        me.lock();
                        me.noData();
                    }
                    me.resetload();
                    isload=false;
                },
                error: function(xhr, type){
                    me.noData();
                    me.resetload();
                    isload=false;
                }
            });
        }
    });
});
$(window).scroll(function(){
    var sc=$(window).scrollTop();
    var rwidth=$(window).width()+$(document).scrollLeft();
    var rheight=$(window).height()+$(document).scrollTop();
    if(sc>0){
        $(".back-top").css("display","block");
        // $(".back-top").css("left",(rwidth-80)+"px");
        // $(".back-topp").css("top",(rheight-120)+"px");
    }else{
        $(".back-top").css("display","none");
    }
});

$('.back-top').on('click', function(e) {
  $.scrollTo({
    endY: 0,
    duration: 200,
  });
});
</script>
</body>
{template 'show/web-gearfooter'}